#inherit kernel
#require recipes-kernel/linux/linux-yocto.inc
require recipes-kernel/linux/linux-mainline-common.inc

LIC_FILES_CHKSUM = "file://COPYING;md5=bbea815ee2795b2f4230826c0c6b8814"

LINUX_VERSION = "5.4"
LINUX_SUBVERSION = ".61"
LINUX_TARBASE = "linux-${LINUX_VERSION}${LINUX_SUBVERSION}"
KERNEL_VERSION_SANITY_SKIP="1"

########### gitee aw-tina ###########
#SRC_URI = " \
#    git://gitee.com/aw-tina/linux-5.4.git;branch=master;protocol=https \
#    "

#SRC_URI += " \
#    file://${LINUX_VERSION}/${LINUX_VERSION}${LINUX_SUBVERSION}/0000-poky-riscv-gcc13-makefile.patch \
#    file://${LINUX_VERSION}/${LINUX_VERSION}${LINUX_SUBVERSION}/0001-fix-hci-tool-error.patch \
#    file://${LINUX_VERSION}/${LINUX_VERSION}${LINUX_SUBVERSION}/0001-Add-HAVE_LD_DEAD_CODE_DATA_ELIMINATION.patch \
#    file://${LINUX_VERSION}/${LINUX_VERSION}${LINUX_SUBVERSION}/0002-fix-CONFIG_LD_DEAD_CODE_DATA_ELIMINATION-config-boot.patch \
#    file://${LINUX_VERSION}/${LINUX_VERSION}${LINUX_SUBVERSION}/0001-Modify-boot-lcd-backlight-on-timing.patch \
#    "
#KBUILD_DEFCONFIG = "d1_defconfig"
#KBUILD_DEFCONFIG = "d1_minimal_defconfig"

#SRC_URI += "file://fb_hw_rotation_support.cfg;subdir=fragments"

# For 64M memory version
# SRC_URI = "git://git@gitee.com/aw-tina/linux-5.4.git;branch=master;protocol=ssh \
#            file://0001-fix-hci-tool-error.patch \
#            file://0001-Add-HAVE_LD_DEAD_CODE_DATA_ELIMINATION.patch \
#            file://0002-fix-CONFIG_LD_DEAD_CODE_DATA_ELIMINATION-config-boot.patch \
#            file://0001-Modify-boot-lcd-backlight-on-timing.patch \
#            file://0002-Modify-lcd-format-for-D1-64M-memory-RGB565.patch \
#            "

# For 64M memory version
# KBUILD_DEFCONFIG_d1 = "d1_64M_defconfig"

# modify cfg example
# SRC_URI_d1 += "file://fragment.cfg"


########### github aw-tina ###########

SRC_URI = " \
    git://gitee.com/XY_With_Z/tina-linux.git;branch=master;protocol=https \
    "

#SRC_URI += " \
#    file://${LINUX_VERSION}/${LINUX_VERSION}${LINUX_SUBVERSION}/0101-patch-tina.patch \
#    file://${LINUX_VERSION}/${LINUX_VERSION}${LINUX_SUBVERSION}/0102-add-board-dts.patch \
#    file://${LINUX_VERSION}/${LINUX_VERSION}${LINUX_SUBVERSION}/0103-tina-config.patch \
#    "
SRC_URI += " \
    file://${LINUX_VERSION}/${LINUX_VERSION}${LINUX_SUBVERSION}/0110-patch-riscv-makefile.patch \
    file://${LINUX_VERSION}/${LINUX_VERSION}${LINUX_SUBVERSION}/0102-add-board-dts.patch \
    file://${LINUX_VERSION}/${LINUX_VERSION}${LINUX_SUBVERSION}/0111-config.patch \
    "

KERNEL_DEVICETREE = " \
    sunxi/board.dtb \
    "
#########

SRCREV="0e74dee00985dbaec8976580861d90cc16b2bade"

DEPENDS += "elfutils-native"

LINUX_TARGET = ""
LINUX_RELEASE = "r1.0"

PV = "${LINUX_VERSION}${LINUX_SUBVERSION}"
S = "${WORKDIR}/${LINUX_TARBASE}"

COMPATIBLE_MACHINE = "(^d1.*)"
KBUILD_DEFCONFIG = "sun20iw1p1_d1_defconfig"


do_configure:append() {
  [ -d ${STAGING_KERNEL_DIR} ] && rm -rf ${STAGING_KERNEL_DIR}
  [ -f ${STAGING_KERNEL_DIR} ] && rm -rf ${STAGING_KERNEL_DIR}

  ln -s ${S}  ${STAGING_KERNEL_DIR}
}

do_install:append() {

   [ -f ${STAGING_KERNEL_BUILDDIR} ] && rm -rf ${STAGING_KERNEL_BUILDDIR}
   [ -d ${STAGING_KERNEL_BUILDDIR} ] && rm -rf ${STAGING_KERNEL_BUILDDIR}

   ln -s ${B}  ${STAGING_KERNEL_BUILDDIR}
}

KCONFIG_MODE="--alldefconfig"

KERNEL_DEPLOYSUBDIR = "${LINUX_TARBASE}"
